DEMO #3: Let's see how we can write programs that change depending on the user's input!

If statements, or conditionals, start with a test that compares two values. If the test statement is true, the code indented underneath runs. If the test statement is not true, the block of code underneath is skipped and the rest of the program runs.

  • Click Run and view the example on the stage. Try running it twice to see results for responding yes or no.

To navigate the page using the TAB key, first press ESC to exit the code editor.

# THIS ACTIVITY IS IN PREVIEW ONLY MODE
  • Run Code
  • Submit Work
  • Next Activity
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)